const DinicAlog = require('./dataStruct/dinic').DinicAlog;
const Graph = require('./dataStruct/graph').Graph;
const common = require('./base/common');

/**
 * 网络流算法测验
 * 
 * @param {*} vertexs 
 */
let netStream = (vertexs) => {
    let graph = new Graph();
    for (let i = 0; i < vertexs.length; ++i) {
        graph.addEdge(vertexs[i][0], vertexs[i][1], vertexs[i][2]);
    }
    let alog = new DinicAlog(graph);

    let results = [];
    results.push("源点：" + graph.calSourcePoint());
    results.push("汇点：" + graph.calMeetingPoint());
    results.push("Dinic计算：" + alog.autoDinic().join(" "));

    common.drawing(graph.generateMST(), "MST");

    return results.join(" ");
}

common.testing([
    [[0, 1, 999], [0, 2, 333], [1, 2, 1]]
])((x) => netStream(x));